#include "dpldrawscan.h"
#include "string.h"
#include <QImage>
#include <QPainter>
#include <QPen>
#include <QPointF>

DplDrawScan::DplDrawScan(QImage* pImage_)
{
    m_pImage = pImage_ ;
}

void DplDrawScan::SetDrawType(DRAW_TYPE nType_)
{
    m_cInfo.nDrawType  = nType_  ;
}

void DplDrawScan::SetDrawInfo(DrawInfo* pInfo_)
{
    memcpy((void*)&m_cInfo , (void*)pInfo_ , sizeof(DrawInfo))  ;
}

void DplDrawScan::Draw()
{
    if(!m_pImage)  return ;
}


void DplDrawAscanH::Draw()
{
    if(!m_pImage)  return ;
    unsigned char* pData = m_pImage->bits() ;
    int pos;
    int _nWideStep = m_pImage->bytesPerLine() ;
    int _nHeight  = m_pImage->height() ;
    int _nWidth   = m_pImage->width()  ;
    for(int i = 0 ; i< _nHeight / 2  ; i++)
    {
        for(int j = 0 ; j < _nWidth / 2 ; j++)
        {
            pos = i * _nWideStep + j*3 ;
            pData[pos++]  = qrand()%255 ;
            pData[pos++ ] = qrand()%255 ;
            pData[pos]    =  qrand()%255;
        }
    }

    for(int i = _nHeight / 2 ; i< _nHeight  ; i++)
    {
        for(int j = _nWidth / 2 ; j < _nWidth  ; j++)
        {
            pos = i * _nWideStep + j*3 ;
            pData[pos++]  = qrand()%255 ;
            pData[pos++ ] = qrand()%255 ;
            pData[pos]    =  qrand()%255;
        }
    }
}

void DplDrawAscanV::Draw()
{
    if(!m_pImage)  return ;
}

void DplDrawBscanH::Draw()
{
    if(!m_pImage)  return ;
    QPainter painter(m_pImage);
    QPen pen(QColor(255 , 0 , 0));
    pen.setWidth(0);
    painter.setPen(pen);
    QPointF pos1 , pos2 ;
    painter.fillRect(0, 0, 400, 400, Qt::black);
    for(int i = 0 ; i < 100 ; i++)
    {
        pos1.setX(qrand()%400);
        pos1.setY(qrand()%400);
        pos2.setX(qrand()%400);
        pos2.setY(qrand()%400);
        painter.drawLine(pos1, pos2) ;
    }

}

void DplDrawBscanV::Draw()
{
    if(!m_pImage)  return ;
}

void DplDrawCscanH::Draw()
{
    if(!m_pImage)  return ;
}

void DplDrawCscanV::Draw()
{
    if(!m_pImage)  return ;
}

void DplDrawSscan::Draw()
{
    if(!m_pImage)  return ;
}

void DplDrawSscanA::Draw()
{
    if(!m_pImage)  return ;
}

void DplDrawSscanL::Draw()
{
    if(!m_pImage)  return ;
}
